import Ember from 'ember';

export default Ember.Controller.extend({
  workers: Ember.computed("model", function(){
    var md = this.get('model'),
        wkhash = md.workers,
        wks = [];
    for(var key in wkhash) {
        wks.push(wkhash[key]);
    }
    return wks;
  }),
  actions: {
    playpause(wid) {
      var self = this;

      Ember.$.ajax({
          method: "GET",
          url: "/mconsolejs/workerstats/toggle",
          data: { wid: wid}
        }).done(function( data ) {
          self.set('model', data);
        });
    }
  }
});
